home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doScaleKeyArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.8 KB  |  220 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  10 Aug 98
  22. //  Author:         mw
  23. //
  24. //  Description:
  25. //        doScaleKeyArgList is the actual proc that is executed from the
  26. //    Edit->Keys->Scale Keys option box or menu
  27. //
  28. //  Input Arguments:
  29. //    $version: The version of this option box.  Used to know how to 
  30. //    interpret the $args array.
  31. //        "1" : $whichRange, $timeRange, $whichMethod, $newStartTime,
  32. //                $newEndTime, $timeScale, $timePivot, $valueScale,
  33. //                $valuePivot, $hierarchy, $doControlPoints, $doShapes,
  34. //                $useChannelBox, $useAllAnimCurves, $selectionConnection
  35. //                $scaleSpecifiedKeys
  36. //        "2" : $options
  37. //
  38. //    $args
  39. //    Version 1
  40. //    [0]        $whichRange                1 : time range all
  41. //                                    2 : use playback range
  42. //                                    3 : use $timeRange
  43. //    [1]        $timeRange                startTime:endTime
  44. //    [2]        $whichMethod            1 : pivot based scaling
  45. //                                    2 : newStartTime:newEndTime scaling
  46. //    [3]        $newStartTime
  47. //    [4]        $newEndTime
  48. //    [5]        $timeScale
  49. //    [6]        $timePivot
  50. //    [7]        $valueScale
  51. //    [8]        $valuePivot
  52. //    [9]        $hierarchy                1 : none
  53. //                                    2 : below
  54. //    [10]    $doControlPoints        0 / 1
  55. //    [11]    $doShapes                0 / 1
  56. //    [12]    $useChannelBox            0 / 1
  57. //    [13]    $useAllAnimCurves        0 / 1
  58. //    [14]    $selectionConnection    name of selection connection to use
  59. //                                    unless $options has "bufferCurve" in which
  60. //                                    case this is the name of the editor
  61. //    [15]    $scaleSpecifiedKeys        0 / 1
  62. //    Version 2
  63. //    [16]    $options                a ':' delimited list of options
  64. //                                    noOptions        an empty placeholder
  65. //                                    bufferCurve        create buffer curves
  66. //
  67. //    Version 3
  68. //    [17]    $fromGraphEditor        0 / 1 
  69. //    [18]    $doDrivenChannels        0 / 1 
  70. //
  71. //  Return Value:
  72. //      The number of curves which were scaled.
  73. //
  74. global proc int doScaleKeyArgList( string $version, string $args[] )
  75. {
  76.     int        $versionNum                = $version;
  77.  
  78.     int        $whichRange                = $args[0];
  79.     string    $timeRange                = $args[1];
  80.     int        $whichMethod            = $args[2];
  81.     float    $newStartTime            = $args[3];
  82.     float    $newEndTime                = $args[4];
  83.     float    $timeScale                = $args[5];
  84.     float    $timePivot                = $args[6];
  85.     float    $valueScale                = $args[7];
  86.     float    $valuePivot                = $args[8];
  87.     string    $hierarchy                = $args[9];
  88.     int        $doControlPoints        = $args[10];
  89.     int        $doShapes                = $args[11];
  90.     int        $useChannelBox            = $args[12];
  91.     int        $useAllAnimCurves        = $args[13];
  92.     string    $selectionConnection    = $args[14];
  93.     int        $scaleSpecifiedKeys        = $args[15];
  94.     string    $options                = ($versionNum >= 2 ? $args[16] : "noOptions");    
  95.     int     $fromGraphEditor        = $versionNum >= 3 ? $args[17] : 1;
  96.     int     $doDrivenKeys            = $versionNum >= 3 ? $args[18] : 1;
  97.  
  98.     string $cmd = "scaleKey ";
  99.  
  100.     //    Set the scale specified key flag.
  101.     //
  102.     $cmd += ("-scaleSpecifiedKeys " + $scaleSpecifiedKeys + " ");
  103.  
  104.     string $realConnection = $selectionConnection;
  105.  
  106.     // Check for the bufferCurve option
  107.     //
  108.     if (match ("bufferCurve", $options) == "bufferCurve") {
  109.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  110.         // Check to see if we need to create buffer curves
  111.         //
  112.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  113.             $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd;
  114.         }
  115.     }
  116.  
  117.     // Get the target objects
  118.     //
  119.     string $members = expandSelectionConnection ($realConnection);
  120.  
  121.     if( $whichRange == 1 ) {
  122.         $timeRange = ":";
  123.     } else if( $whichRange == 2 ) {
  124.         $timeRange = ( `playbackOptions -q -min` + ":" + 
  125.                        `playbackOptions -q -max` );
  126.     }
  127.  
  128.     int $keys = `keyframe -sl -q -kc`;
  129.     
  130.     if( !$fromGraphEditor || ( $keys == 0 ) ) {
  131.         $cmd = ( $cmd + "-time \"" + $timeRange + "\" " );
  132.  
  133.         if( $fromGraphEditor || $doDrivenKeys ) {
  134.             $cmd = ( $cmd + "-float \"" + $timeRange + "\" " );
  135.         }
  136.     }
  137.     
  138.     if ($whichMethod == 1) {
  139.         $cmd += "-timeScale " + $timeScale;
  140.         $cmd += " -timePivot " + $timePivot;
  141.         $cmd += " -floatScale " + $timeScale;
  142.         $cmd += " -floatPivot " + $timePivot;
  143.         $cmd += " -valueScale " + $valueScale;
  144.         $cmd += " -valuePivot " + $valuePivot + " ";
  145.     } 
  146.     else {
  147.         $cmd += "-newStartTime " + $newStartTime;
  148.         $cmd += " -newStartFloat " + $newStartTime;
  149.         $cmd += " -newEndTime " + $newEndTime;
  150.         $cmd += " -newEndFloat " + $newEndTime + " ";
  151.     }
  152.     
  153.     if( $useAllAnimCurves ) {
  154.         int     $i;
  155.  
  156.         string     $curves[] = `ls -type animCurveTL`;
  157.         for( $i = 0; $i < size( $curves ); $i++ ) {
  158.             $cmd = ( $cmd + " " + $curves[$i] );
  159.         }
  160.         $curves = `ls -type animCurveTU`;
  161.         for( $i = 0; $i < size( $curves ); $i++ ) {
  162.             $cmd = ( $cmd + " " + $curves[$i] );
  163.         }
  164.         $curves = `ls -type animCurveTA`;
  165.         for( $i = 0; $i < size( $curves ); $i++ ) {
  166.             $cmd = ( $cmd + " " + $curves[$i] );
  167.         }
  168.         $curves = `ls -type animCurveTT`;
  169.         for( $i = 0; $i < size( $curves ); $i++ ) {
  170.             $cmd = ( $cmd + " " + $curves[$i] );
  171.         }
  172.     }
  173.     else if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) {
  174.         string $syntax[] = keySetOptionBoxCommon( { "scaleKey", "unknown", 
  175.                                                     "channelBoxSyntax" } );
  176.         if( size( $syntax[0] ) == 0 ) {
  177.             $cmd = "";
  178.             warning( "No channels selected in channel box" );
  179.         } else {
  180.             $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " );
  181.  
  182.             $cmd = $cmd + $syntax[0];
  183.         }
  184.     }
  185.     else if( $members != "" ) {
  186.         // Only add the selection connection to the cmd if
  187.         // there are NO active keys (in the graph editor),
  188.         // or we're not called from the graphEditor.
  189.         //
  190.         int $keys = `keyframe -sl -q -kc`;
  191.         if( $keys == 0 || !$fromGraphEditor ) {
  192.             if ($members == "{}") {
  193.                 $cmd = "";
  194.                 warning ("No objects selected to scale keys");
  195.             }
  196.             else {
  197.                 $cmd = ($cmd + 
  198.                     "-hierarchy " + $hierarchy + " " +
  199.                     "-controlPoints " + $doControlPoints + " " +
  200.                     "-shape " + $doShapes + " " +
  201.                     $members);
  202.             }
  203.         }
  204.     }
  205.     else {
  206.         $cmd = ( $cmd + 
  207.                  "-animation objects " +  
  208.                  "-hierarchy " + $hierarchy + " " +
  209.                  "-controlPoints " + $doControlPoints + " " +
  210.                  "-shape " + $doShapes + " " );
  211.     }
  212.     
  213.     if( $cmd == "" ) {
  214.         return 0;
  215.     } else {
  216.         return evalEcho( $cmd );
  217.     }
  218. }
  219.  
  220.